package com.woniuxy01;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 作者
 * @create 2025-09-15 14:29
 */
public class Test03 {
    public static void main(String[] args)  {
        showDirectory("D:\\code");
        int age;
        List<String> strings = new ArrayList<String>();
        strings.add("<UNK>");
        strings.add("<UNK>");
        strings.add("<UNK>");
        strings.add("<UNK>");
    }

    public static  void showDirectory(String path){
        File file = new File(path);
        //获取当前目录的一级(第一层)目录
        File[] files = file.listFiles();
        for(File myFile : files){
            if (myFile.isFile()) {
                //如果是文件，直接输出
                System.out.println(myFile.getAbsolutePath());
            }else{
                //如果是目录，遍历目录
                showDirectory(myFile.getAbsolutePath());
            }
        }
    }

    public static int fibonacci(int i){
        if(i==1 || i==2) {
            return 1;
        }else{
            return fibonacci(i-1)+fibonacci(i-2);
        }
    }

    public static int sum(int i) {
        if(i==1){
            return 1;
        }else{
            return i+sum(i-1);
        }
    }

    private static void testXxx() {
        System.out.println("testXxx");
        testXxx();
    }

    private static void test03() {
        File file = new File("d:\\aaa");
        //
        String[] list = file.list();
        for(String s : list){
            System.out.println(s);
        }

        File[] files = file.listFiles();
        for(File f : files){
            System.out.println(f.getName());
            System.out.println(f.getPath());
            System.out.println(f.getAbsolutePath());
            System.out.println("-----------------");
        }
    }

    private static void test02() throws IOException {
        //        File file1 = new File("D:\\aaa\\bbb\\ccc\\ddd");
//        boolean exists = file1.exists();
//        System.out.println(file1.mkdir());
//        System.out.println(file1.mkdirs());

        File file2 = new File("D:\\aaa\\b.txt");
        file2.createNewFile();
    }

    private static void test01() {
        File file1 = new File("D:\\aaa");
        File file2 = new File("D:\\aaa\\a.txt");
        System.out.println(file1.isDirectory());
        System.out.println(file1.isFile());
        System.out.println(file2.isDirectory());
        System.out.println(file2.isFile());
        File file3 = new File("D:\\aaa", "a.txt");
        System.out.println(file3);
    }
}
